/**
 * Created by Celebration-Grey on 2017/4/21.
 */

weibo.picture = {};

weibo.picture.picLi = function () {
    var text = '<li class="pic"><div style="background:url(http://wx3.sinaimg.cn/square/005YRgL8gy1fetbe5nshxj306k06kmxi.jpg) center center;width:80px;height:80px;"></div><span class="picbg"></span><a href="javascript:;"class="ico_editpic"></a><a href="javascript:;"class="ico_delpic"></a><span class="tag_v2"><a href="javascript:;"class="W_btn_d"><em class="W_ficon ficon_add">+</em>标签</a></span><i style="display:none;"class="W_icon icon_taged_pic"></i></li>';
    return $(text);
};

weibo.picture.addLi = function () {
    var text = '<li class="add"style="position: relative;"><a href="javascript:;"title="">+</a><div style="position: absolute; left: 0px; top: 0px; display: block; overflow: hidden; opacity: 0; width: 80px; height: 80px; background-color: rgb(0, 0, 0);"><form id="pic_upload"name="pic_upload"target="upload_target"enctype="multipart/form-data"method="POST"style="overflow: hidden; opacity: 0; height: 80px; width: 80px;"><input type="file"hidefoucs="true"name="pic1"style="cursor:pointer;width:1000px;height:1000px;position:absolute;bottom:0;right:0;font-size:200px;"multiple="multiple"></form></div></li>';
    return $(text);
};

weibo.picture.uploadBox = function () {
    var text = '<div class="W_layer W_layer_pop"id="layer_pictures"style="left: 4px; top: 40px;"><div class="content"><div class="W_layer_close"><a href="javascript:void(0)"class="W_ficon ficon_close S_ficon glyphicon glyphicon-remove" style="top: 5px;"></a></div><div><div class="layer_pic_list clearfix"><div class="W_layer_con_tit"><h1 class="W_f14 W_fb">本地上传</h1><h2 class="clearfix"><span class="tit_txt W_fl">共<em class="num_totla">0</em>张，还能上传<em class="num_remain">9</em>张</span></h2></div><ul class="drag_pic_list clearfix"></ul></div></div></div></div>';
    var $box = $(text);
    $box.find('.drag_pic_list').append(weibo.picture.addLi());
    $box.find('.glyphicon-remove').click(function () {
        $(this).parents('.func_area').find('.picture-action').removeClass('btn_disable');
        $(this).parents('#layer_pictures').remove();
    });
    return $box;
};

weibo.picture.picUpClick = function () {
    $('.picture-action').click(function () {
        $(this).parents('.func_area').find('.W_layer').remove();
        $(this).parents('.func_area').children('.kind').find('a').removeClass('btn_disable');
        $(this).addClass('btn_disable');
        $(this).parents('.func_area').append(weibo.picture.uploadBox());
    });
};